<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    :footer="null"
    cancelText="关闭">

    <table id="table_report" class="table table-striped table-bordered table-hover">

      <tr>
        <td style="width:90px;text-align: center;padding-top: 65px;">基本信息:</td>
        <td>
          <p style="float: left;">


            附加数据：<span id="attach">
           {{ result.attach }}
                    </span><br>

            返回码：<span id="returnCode">
           {{ result.returnCode }}
                    </span><br>
            返回码说明：<span id="returnMsg">
           {{ result.returnMsg }}
                    </span><br>

            商户系统订单号：<span id="outTradeNo">
           {{ result.outTradeNo }}
                    </span><br>

            支付完成时间：<span id="payTime">
           {{ result.payTime }}
                    </span><br>

            创建时间：<span id="createTime">
           {{ result.createTime }}
                    </span><br>
          </p>
        </td>
      </tr>

      <tr>
        <td style="width:90px;text-align: center;padding-top: 75px;">详情:</td>
        <td>
          <p style="float: left;">


            订单总金额（元）：<span id="totalAmt">
           {{ result.totalAmt / 100}}
                    </span><br>


            积分抵扣金额（元）：<span id="pointAmt">
           {{ result.pointAmt / 100}}
                    </span><br>


            电子券抵扣金额（元）：<span id="ecouponAmt">
           {{ result.ecouponAmt }}
                    </span><br>


            优惠立减金额（元）：<span id="merDiscAmt">
           {{ result.merDiscAmt / 100}}
                    </span><br>


            优惠券金额（元）：<span id="couponAmt">
           {{ result.couponAmt / 100}}
                    </span><br>
            总优惠金额（元）：<span id="totalDiscAmt">
           {{ result.totalDiscAmt / 100}}
                    </span><br>

            用户实际扣减金额（元）：<span id="paymentAmt">
           {{ result.paymentAmt / 100}}
                    </span><br>
          </p>
        </td>
      </tr>

      <tr>
        <td style="text-align: center;" colspan="10">
          <a-button type="primary" @click="close">关闭</a-button>
        </td>
      </tr>
    </table>

  </a-modal>
</template>

<script>
import {httpAction} from '@/api/manage'
import pick from 'lodash.pick'
import moment from "moment"

export default {
  name: "IcbcAggregatePaymentNotifyLogModal",
  data() {
    return {
      title: "操作",
      visible: false,
      model: {},
      labelCol: {
        xs: {span: 24},
        sm: {span: 5},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 16},
      },
      result: {},
      confirmLoading: false,
      form: this.$form.createForm(this),
      validatorRules: {},
      url: {
        add: "/b2cpaymentpay/icbcAggregatePaymentNotifyLog/add",
        edit: "/b2cpaymentpay/icbcAggregatePaymentNotifyLog/edit",
      },
    }
  },
  created() {
  },
  methods: {
    add() {
      this.edit({});
    },
    edit(record) {
      if(record.returnCode === 0)
      {
        record.returnCode ='交易成功'
      }
      else {
        record.returnCode = '交易失败'
      }
      Object.assign(this.result, record);
      this.visible = true;
    },
    close() {
      this.$emit('close');
      this.visible = false;
    },
    handleOk() {
      const that = this;
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true;
          let httpurl = '';
          let method = '';
          if (!this.model.id) {
            httpurl += this.url.add;
            method = 'post';
          } else {
            httpurl += this.url.edit;
            method = 'put';
          }
          let formData = Object.assign(this.model, values);
          //时间格式化

          httpAction(httpurl, formData, method).then((res) => {
            if (res.success) {
              that.$message.success(res.message);
              that.$emit('ok');
            } else {
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.confirmLoading = false;
            that.close();
          })


        }
      })
    },
    handleCancel() {
      this.close()
    },


  }
}
</script>

<style lang="less" scoped>

</style>